// components/rankinglist/index.js
const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    // 这里定义了id属性，属性值可以在组件使用时指定
    selectid: {
      type: Number,
      value: 0
    },
    baseimgaeUrl:{
      type:String,
      value:""
    },
    selectarea:{
      type:String,
      value:"全国"
    },
    rankingbyyear: {
      type: Object,
      value: undefined,
      observer: function (newVal, oldVal) {

        this._rankingbyyearpropertyChange(newVal, oldVal);

      } // 属性被改变时执行的函数（可选），也可以写成在methods段中定义的方法名字符串, 如：'_propertyChange'

    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    staticUrl: app.globalData.staticUrl,
    currentpageheight: 0, //设置高度
    currentTab: 0,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    //打开playerscorecinfo 页面 
    _openplayerinfo(e) {
      this.setData({
        selectplayerid: e.currentTarget.dataset.id,
        teamorplayer: 0
      });
      let id = this.data.selectplayerid;
      // 微信小程序中是通过triggerEvent来给父组件传递信息的
      this.triggerEvent('_openplayerinfo', {
        selectid: id
      }) // 将参数的形式传递给父组件

    },


    _rankingbyyearpropertyChange: function (newVal, oldVal) {
      this.fillheight();
     console.log(newVal);

    },

    _matchleaderspropertyChange: function (newVal, oldVal) {
      this.fillheight();

    },

    ///填充swiper的高度，它不能自适应
    fillheight: function () {
          
     
    },

    //  tab切换逻辑
    swichNav: function (e) {
      var that = this;
      if (that.data.currentTab === e.target.dataset.current) {

        return false;
      } else {
        that.setData({
          currentTab: e.target.dataset.current
        })

        that.fillheight();
      }
    },

    bindChange: function (e) {
      var that = this;
      that.setData({
        currentTab: e.detail.current
      });
      that.fillheight();
    },

       //控制回到顶部按钮的显示与消失
       _scrollTopFun(e) {

        let that = this;
        var objtitle = that.createSelectorQuery();
        objtitle.select("#vranking").boundingClientRect(function (rect) {
          var top = rect.top;
          console.log(top);
          if (top <= 0) {
            that.setData({
              istopnav: true
            })
  
          } else {
            that.setData({
              istopnav: false
            })
          }
        }).exec();
  
      }
  }
})